#define _CRT_SECURE_NO_WARNINGS
#include<iostream>

using namespace std;

class Solution {
public:
    bool isPalindrome(string s)
    {
        int left = 0, right = s.size() - 1;
        while (left <= right)
        {
            while (left <= right && !isLetter_numbers(s[left])) left++;
            while (left <= right && !isLetter_numbers(s[right])) right--;

            while (left <= right && s[left] == s[right])
            {
                left++;
                right--;
            }

            if (left <= right && isLetter_numbers(s[left]) && isLetter_numbers(s[right]) && s[left] != s[right])
                if (isLetter(s[left]) && isLetter(s[right]) && s[left] - 32 == s[right] || s[right] - 32 == s[left])
                {
                    left++;
                    right--;
                    continue;
                }
                else return false;
        }

        return true;

    }

    bool isLetter_numbers(char ch)
    {
        if (ch >= 'a' && ch <= 'z') return true;
        else if (ch >= 'A' && ch <= 'Z') return true;
        else if (ch >= '0' && ch <= '9') return true;
        else return false;
    }

    bool isLetter(char ch)
    {
        if (ch >= 'a' && ch <= 'z') return true;
        else if (ch >= 'A' && ch <= 'Z') return true;
        else return false;
    }
};

int main()
{
    string s = "0P";
    cout <<Solution().isPalindrome(s);
}